package api

import (
	"github.com/gin-gonic/gin"
	"yybk/serializer"
	"yybk/service"
)

type Responder struct {
}

func (Responder) Submit(c *gin.Context) {
	var service service.ResponderTeacherSubmit
	if err := c.ShouldBind(&service); err == nil {
		if data, err := service.Insert(); err != nil {
			c.JSON(200, err)
		} else {
			res := serializer.Responder{}.BuildResponderTeacherSubmit(data)
			c.JSON(200, res)
		}
	} else {
		c.JSON(200, ErrorResponse(err))
	}
}

func (Responder) Stop(c *gin.Context) {
	var service service.ResponderTeacherStop
	if err := c.ShouldBind(&service); err == nil {
		if _, err := service.Stop(); err != nil {
			c.JSON(200, err)
		} else {
			res := serializer.ResponderTeacherStop{Code: 0}
			c.JSON(200, res)
		}
	} else {
		c.JSON(200, ErrorResponse(err))
	}
}
